package com.gushuang.leetcode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

public class groupAnagrams {
    public List<List<String>> groupAnagrams(String[] strs) {
        return new ArrayList<>(Arrays.stream(strs).collect(Collectors.groupingBy(new Function<String, String>() {
            @Override
            public String apply(String str) {
                char[] charArray = str.toCharArray();
                Arrays.sort(charArray);
                return new String(charArray);
            }
        })).values());
    }
}
